//
//  XFXViewTableViewCell.m
//  XFXnews
//
//  Created by dllo on 16/1/27.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "XFXViewTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface XFXViewTableViewCell()
@property (weak, nonatomic) IBOutlet UILabel *XFXTittle;
@property (weak, nonatomic) IBOutlet UILabel *XFXStore;
@property (weak, nonatomic) IBOutlet UIImageView *XFXVoice;
@property (weak, nonatomic) IBOutlet UILabel *XFXTime;
@property (weak, nonatomic) IBOutlet UILabel *XFXWatch;
@property (weak, nonatomic) IBOutlet UILabel *XFXComment;

- (IBAction)buttonAction:(id)sender;


@end

@implementation XFXViewTableViewCell

-(void)setModel:(XFXVoiceModel *)model{
    
    
//     self.myCellView = self.contentView
    _model = model;
    
    // 头
    self.XFXTittle.text = _model.title;
    self.XFXTittle.font = [UIFont systemFontOfSize:15.0];
    
    // 小标题
    self.XFXStore.text = model.descrip;
    self.XFXStore.font = [UIFont systemFontOfSize:13.0];
    
    // 图片
    NSURL *url = [NSURL URLWithString:_model.cover];
    [self.XFXVoice sd_setImageWithURL:url placeholderImage:nil];
    
    // 人数
    CGFloat count = [_model.playCount intValue];
    NSString *XFXWatch;
    if (count > 10000) {
        XFXWatch = [NSString stringWithFormat:@"%.1f万",count/10000];
    }else{
        
        XFXWatch = [NSString stringWithFormat:@"%0.f",count];
    }
    self.XFXWatch.text = XFXWatch;
    
    // 点评
    self.XFXComment.text = [NSString stringWithFormat:@"%@",_model.replyCount];

    // 时间
    self.XFXTime.text = [NSString stringWithFormat:@"%02d:%02d",_model.length.intValue/60,_model.length.intValue%60];
    
    
    self.contentView.layer.cornerRadius = 5;
    self.contentView.layer.borderWidth = 1;
    self.contentView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.contentView.layer.masksToBounds = YES;
}

- (IBAction)buttonAction:(id)sender {
    [self.delegate show:self.indexPath];
}
@end
